#include <iostream>
#include <string>
#include <map>
using namespace std;
class Monster{
public:
virtual void showName(void)=0;
};
class Goblin: public Monster{
void showName(void){
cout<<"Edit Goblin"<<endl;
}
};
class Ghost: public Monster{
void showName(void){
cout<<"Edit Ghost"<<endl;
}
};
class MonMgr{
public:
void newMonster(const string& name){
Monster* pMon=createMonster();
ObjPool_[name]=pMon;
pMon->showName();
}
virtual Monster* createMonster()=0;
private:
map<string, Monster*> ObjPool_;
};
class GoblinMgr: public MonMgr{
Monster* createMonster(){
return new Goblin;
}
};
class GhostMgr: public MonMgr{
Monster* createMonster(){
return new Ghost;
}
};
int main(void){
GoblinMgr goblin;
goblin.newMonster("goblin");
GhostMgr ghost;
ghost.newMonster("ghost");
return 0;
}